﻿CREATE PROCEDURE dbo.usp_tProject_Insert
	@uUserId		UNIQUEIDENTIFIER, 
	@sName			NVARCHAR(100),
	@sDescription	NVARCHAR(MAX)
AS
	BEGIN TRANSACTION
		BEGIN TRY
			INSERT INTO tProject
			(
				uUserId,
				sName,
				sDescription
			)
			VALUES
			(
				@uUserId,
				@sName,
				@sDescription
			)
		END TRY
		BEGIN CATCH
			SELECT	ERROR_NUMBER()		AS ErrorNumber,			
					ERROR_SEVERITY()	AS ErrorSeverity,	
					ERROR_STATE()		AS ErrorState,
					ERROR_PROCEDURE()	AS ErrorProcedure,	
					ERROR_LINE()		AS ErrorLine,			
					ERROR_MESSAGE()		AS ErrorMessage;

			IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
			RETURN -1;
		END CATCH;

	IF @@TRANCOUNT > 0 COMMIT TRANSACTION
	RETURN SCOPE_IDENTITY();